package cc.idoone.joddhttp.demo;

import jodd.http.HttpBrowser;
import jodd.http.HttpRequest;

import java.io.UnsupportedEncodingException;

/**
 * @author hemj
 * @version 2017/8/1
 */
public class HttpBrowserDemo {
    private static final String URL = "http://localhost:8088/joddhttp/";

    public static void main(String[] args) throws UnsupportedEncodingException {
        HttpBrowser browser = new HttpBrowser();

        HttpRequest request = HttpRequest.get(URL);
        browser.sendRequest(request);

        // request is sent and response is received

        // process the page:
        String page = browser.getPage();
        System.out.println(new String(page.getBytes("ISO-8859-1"), "UTF-8"));

        // create new request
        HttpRequest newRequest = HttpRequest.post(URL);

        browser.sendRequest(newRequest);
    }
}
